<template>
  <div>
    <el-dialog :title="$t('action.add')" width="70%" class="icon-dialog" :visible.sync="show" @open="open" :before-close="closeForm" append-to-body>
      <el-form :size="size" ref="form" :model="form" :rules="rules" :label-width="$store.getters.device !== 'mobile'?'16%':'90px'">
        <el-row >
          <el-col :span="24">
            <el-form-item :label="$t('field.PrdIronTray_billNo')" prop="billNo">
              <el-input v-model="form.billNo" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.PrdIronTray_billNo')})">
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button :size="size" :loading="loading" type="primary" @click="submit" >
          <span v-if="!loading">{{$t('system.confirm')}}</span>
          <span v-else>{{$t('system.submitting')}}</span>
        </el-button>
        <el-button :size="size" @click="closeForm">{{$t('system.cancel')}}</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { add } from '@/api/app/prdirontray'



export default {
  name:'prdIronTrayadd',
  components: {

  },
  props: {
    show: {
      type: Boolean,
      default: false
    },
    size: {
      type: String,
      default: 'small'
    },
    querys:{
      type:Object,
    },
  },
  data(){
    return {
      dialog:{
      },

      form: {
        billNo:''

      },
      initial:{},
      loading:false,
      rules: {
      }
    }
  },
  watch:{
    show(val){
      if(val){
      }
    }
  },
  methods: {
    open(){
      if(this.querys){
      }
    },
    submit(){
      this.$refs['form'].validate(valid => {
        if(valid) {
          this.loading = true
          add(this.form).then(res => {
            if(res.status == 200){
              this.$message({message: this.$t('system.success'), type: 'success'})
              this.$emit('refresh_list')
              this.closeForm()
            }
          }).catch(()=>{
            this.loading = false
          })
        }
      })
    },
    closeForm(){
      this.$emit('update:show', false)
      this.loading = false
      if (this.$refs['form']!==undefined) {
        this.$refs['form'].resetFields()
      }
    },
  }
}
</script>
<style scoped lang="scss">
@import '@/assets/scss/common.scss';
</style>
